home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d20
/
vp2_409e.szh
/
STDIO.C
< prev
next >
Wrap
Text File
|
1991-06-27
|
6KB
|
232 lines
/*
$Header: stdio.c 3.3 87/12/12 00:45:26 Bob Exp $
The Conference Mail System
This module was originally written by Bob Hartman
Sysop of FidoNet node 1:132/101
Spark Software, 427-3 Amherst St, CS 2032, Suite 232, Nashua, NH 03061
The Conference Mail System is a complete Echomail processing package. It
is a superset of the original Echomail utilities created by Jeff Rush, and
also contains ideas gleaned from the ARCmail, Renum, oMMM, MGM, and Opus
programs that were created by various software authors.
This program source code is being released with the following provisions:
1. You are free to make changes to this source code for use on your own
machine, however, altered source files may not be distributed without the
consent of Spark Software.
2. You may distribute "patches" or "diff" files for any changes that you
have made, provided that the "patch" or "diff" files are also sent to Spark
Software for inclusion in future releases of the entire package. A "diff"
file for the source archives may also contain a compiled version, provided
it is clearly marked as not being created from the original source code.
No other executable versions may be distributed without the consent of
Spark Software.
3. You are free to include portions of this source code in any program you
develop, providing: a) Credit is given to Spark Software for any code that
may is used, and b) The resulting program is free to anyone wanting to use
it, including commercial and government users.
4. There is NO technical support available for dealing with this source
code, or the accompanying executable files. This source code is provided
as is, with no warranty expressed or implied (I hate legalease). In other
words, if you don't know what to do with it, don't use it, and if you are
brave enough to use it, you're on your own.
Spark Software may be contacted by modem at (603) 888-8179 (node 1:132/101)
on the public FidoNet network, or at the address given above.
To use this code you will need Microsoft C version 4.0, and also Microsoft
Macro Assembler version 4.0.
*/
/*
$Log: stdio.c $
* Revision 3.3 87/12/12 00:45:26 Bob
* Source code release
*
*/
#include <stdio.h>
#include <fcntl.h>
#include <sys\types.h>
#include <sys\stat.h>
#include <io.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "fastecho.h"
#define DEBUG 0
extern WBUFFER wbuffs[];
int fast_close (int f)
{
if (wbuffs[f].wsize > 0)
{
write (f, wbuffs[f].wbuff, wbuffs[f].wsize);
wbuffs[f].wsize = 0;
wbuffs[f].wptr = wbuffs[f].wbuff;
}
return (close (f));
}
long fast_lseek (
int f,
long offs,
int org)
{
(void) lseek (f, 0L, SEEK_CUR);
if (wbuffs[f].wsize > 0)
{
write (f, wbuffs[f].wbuff, wbuffs[f].wsize);
wbuffs[f].wsize = 0;
wbuffs[f].wptr = wbuffs[f].wbuff;
}
return (lseek (f, offs, org));
}
int fast_write (
int f,
char *st,
int l)
{
int ctr, savel;
WBUFFER *w;
w = &wbuffs[f];
if (w->wsize < 0)
{
return (write (f, st, l));
}
savel = l;
ctr = 0;
do
{
if (w->wsize + l > BIGSIZE)
{
memcpy (w->wptr, &st[ctr], BIGSIZE - w->wsize);
l -= (BIGSIZE - w->wsize);
ctr += (BIGSIZE - w->wsize);
w->wsize = 0;
w->wptr = w->wbuff;
if (write (f, w->wbuff, BIGSIZE) != BIGSIZE)
{
w->wsize = 0;
return (-1);
}
}
else
{
memcpy (w->wptr, &st[ctr], l);
w->wsize += l;
w->wptr += l;
l = 0;
}
}
while (l != 0);
return (savel);
}
int fast_read (
int f,
char *st,
int l)
{
int ctr, savel;
WBUFFER *w;
w = &wbuffs[f];
if (w->wsize < 0)
{
return (read (f, st, l));
}
savel = l;
ctr = 0;
do
{
if (w->wsize == 0)
{
w->wptr = w->wbuff;
w->wsize = read (f, w->wbuff, BIGSIZE);
if (w->wsize <= 0)
{
w->wsize = 0;
return (savel - l);
}
}
if (w->wsize - l < 0)
{
memcpy (&st[ctr], w->wptr, w->wsize);
l -= w->wsize;
ctr += w->wsize;
w->wptr = w->wbuff;
w->wsize = read (f, w->wbuff, BIGSIZE);
if (w->wsize <= 0)
{
w->wsize = 0;
return (savel - l);
}
}
else
{
#if DEBUG
printf ("doing a memcpy\n");
#endif
memcpy (&st[ctr], w->wptr, l);
w->wsize -= l;
w->wptr += l;
l = 0;
}
}
while (l != 0);
return (savel);
}
char *echo_fgets(
char *s,
int n,
FILE *fp)
{
return(fgets (s, n, fp));
}
int get_word (
char **from,
char *new)
{
int did;
did = 0;
if ((**from == '\r') || (**from == '\0') || (**from == 0x1a))
return (0);
while (isspace (**from) || (**from == '#'))
++(*from);
while (**from)
{
*new = **from;
if (isspace (*new))
break;
++(*from);
++new;
++did;
}
*new = '\0';
return (did);
}